/**
 * @param {number[]} nums
 * @return {number}
 */
var removeDuplicates = function (nums) {
  for (let i = 0; i < nums.length; i++) {
    let index = nums.lastIndexOf(nums[i])
    if (index != i) {
      nums.splice(index, 1)
      i--
    }
  }
  return nums.length
};

let nums = [1, 1, 2];
nums = [0, 0, 1, 1, 1, 2, 2, 3, 3, 4];
removeDuplicates(nums)